home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 4.1 KB | 136 lines | [TEXT/ttxt] |
- --<<<-
- -- Filename:
- -- scrllprs.sx
-
- -- Other files required
- -- textprin.sx
-
- -- Purpose:
- -- Defines classes that are used in the test for printing text.
-
- --======================================================================================
- -- ScrollingTextPresenter
- -- Creates a ScrollingPresenter with only the vertical scrollbar and which
- -- uses a TextPresenter (or TextEdit) as its targetPresenter.
- --
- -- Parameters:
- -- same as ScrollingPresenter
- --
- -- Usage:
- -- new ScrollingTextPresenter targetPresenter:[TextPresenter]
- --
- -- Main classes used:
- -- ScrollingPresenter
- -- ScrollBar
- --======================================================================================
- class ScrollingTextPresenter (ScrollingPresenter)
- end
-
- method init self {class ScrollingTextPresenter} #rest args -> (
-
- apply nextmethod self fill:whitebrush stroke:(new Brush color:redcolor) args
- local aRect := new Rect x2:16 y2:16
- -- Create presenters for the different parts of the scrollbar
- local redRect := new TwoDShape boundary:(new rect x2:16 y2:16) fill:(new Brush color: redColor) stroke: blackBrush
- local blueRect := new TwoDShape boundary:(new rect x2:16 y2:16) fill:(new Brush color: blueColor) stroke: blackBrush
- local greenRect := new TwoDShape boundary:(new rect x2:16 y2:16) fill:(new Brush color: greenColor) stroke: blackBrush
- local yellowRect := new TwoDShape boundary:(new rect x2:16 y2:16) fill:(new Brush color: yellowColor) stroke: blackBrush
-
- -- Create a vertical scrollbar
- local theScrollbar := new scrollBar orientation:@vertical
- theScrollbar.thumbStencil := aRect
- theScrollbar.decrementStencil := aRect
- theScrollbar.incrementStencil := aRect
- theScrollbar.stepAmount := 5
- theScrollbar.pageAmount := 20
- theScrollbar.directDrag := true
-
- self.vertScrollbar := theScrollbar
-
- return self
- )
-
-
- --======================================================================================
- -- TextWindow
- -- Creates an Window which contains a scrolling text field and 3 buttons. Defines
- -- a printWindow method for the Window subclass that prints the text edit.
- --
- -- Parameters:
- -- same as Window
- --
- -- Usage:
- -- new TextWindow
- --
- -- Main classes used:
- -- Window
- -- ScrollingTextPresenter
- -- CutCopyPasteButtons
- --======================================================================================
- class TextWindow (Window)
- instance variables
- textEd
- scrpres
- end
-
- method init self {class TextWindow} #rest args -> (
- apply nextmethod self boundary:(new rect x2:560 y2:320) \
- name:"Scrollable/Editable Text" \
- fill:blackBrush centered:true args
-
- -- Import plain text file
- local theStream := getStream theScriptDir "text.rtf" @readable
- local theText := importMedia theImportExportEngine theStream @text @rtf @richtext
-
- -- Create a presenter to display the text
- self.textEd := new TextEdit boundary:(new rect x2:540 y2:1024) target:theText
- self.textEd.cursor := new rect x1:0 y1:-12 x2:2 y2:4 --create an visible insertion point for the text
- self.textEd.cursorbrush := new brush color:blackcolor
- self.textEd.selectionforeground := new brush color:redColor
- self.textEd.selectionbackground := new brush color:yellowColor
-
- -- Add text to a scrolling text field
- self.scrpres := (new ScrollingTextPresenter targetPresenter:self.textEd)
- self.scrpres.width := 560; self.scrpres.height := 320
-
- -- Add scrolling text field to window
- append self self.scrpres
-
- -- Define the actuator controller to control the pushbuttons
- local actControl := new actuatorController space:self
- actControl.wholespace := true
-
- return self
- )
-
- method printWindow self {class TextWindow} -> (
- threadCriticalUp()
- self.compositor.enabled := false
-
- self.scrpres.targetPresenter := undefined
-
- printText self.textEd #(1, 1, 1, 1) @inches
-
- self.scrpres.targetPresenter := self.textEd
-
- self.compositor.enabled := true
- threadCriticalDown()
- )
-
- method cut self {class TextWindow} -> (
- cut self.textEd
- )
-
- method copy self {class TextWindow} -> (
- copy self.textEd
- )
-
- method paste self {class TextWindow} -> (
- paste self.textEd
- )
-
- global win := new TextWindow
- show win
- -->>>
-
-